package com.foling.system.controller.mall;

import com.foling.system.entity.Product;
import com.foling.system.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class IndexController {
    @Autowired
    ProductService productService;
    @GetMapping({"/index", "/", "/index.html"})
    public String indexPage(HttpServletRequest request) {
        List<Product> products = productService.list();
        request.setAttribute("products",products);
        return "mall/index";
    }
    //转到登录页面
    @GetMapping({"/login", "login.html"})
    public String loginPage() {
        return "mall/login";
    }

    //转到注册页面
    @GetMapping({"/register", "register.html"})
    public String registerPage() {
        return "mall/register";
    }

}
